package com.example.demodaxue;

import com.daxue.lcm.api.grpc.client.DynamicLoadingGrpcServiceClient;
import com.daxue.lcm.api.grpc.model.DynamicResourceConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

@SpringBootApplication
@RestController
public class DemodaxueApplication {

    public static void main(String[] args) throws Exception {
        ConfigurableApplicationContext applicationContext =
            SpringApplication.run(DemodaxueApplication.class, args);

        DynamicLoadingGrpcServiceClient dynamicLoadingGrpcServiceClient = applicationContext.getBean(DynamicLoadingGrpcServiceClient.class);

        DynamicResourceConfig dynamicResourceConfig =
            dynamicLoadingGrpcServiceClient.configReadByCode("tn-123425647", "dl-code");


        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        System.out.println("--------------start print beanDefinitionNames ----------");
        ArrayList<String> beanDefinitionNamesList = new ArrayList<>(Arrays.asList(beanDefinitionNames));
        beanDefinitionNamesList.forEach(m -> System.out.println(m));

        System.out.println("--------------end print beanDefinitionNames ----------");

    }


    @Autowired
    Map testMap;


    @GetMapping("/hello")
    public Map hello() {
        return testMap;
    }

}
